
// 渲染网页图片

$.get('http://chst.vip:1234/api/getindexmenu')
.then(res=>{
    // console.log(res);
    let {result:thing} = res //解构赋值
    // console.log(thing);
    let html =""  
    thing.forEach(item => {
        // item.img
        // console.log(item.img);
        // item.name
        // console.log(item.name);
        let str = item.img
        let str1 = str.slice(10,str.length-1)
        let str2 = '<img src ="../assets/' + str1
        // 
        html+=`
        <div>
            <a href="pages/${item.titlehref}">${str2}</a>
            <p>${item.name}</p>
        </div>
        `
    });
    $('#nav').append(html)


    // 更改a标签的地址
    $('#nav div:eq(7) a').attr('href','#')
    // console.log($('#nav div:eq(7) a'));

    // 点击切换效果
    $("#nav div:eq(7)").click(function(){
        // console.log($('#nav div:eq(7) a'));
        // $('#nav div:eq(7) a').hide()
        $("#nav div:gt(7)").toggle(500,"linear",function(){

        })
    })
})





// 渲染商品页面
fetch("http://chst.vip:1234/api/getmoneyctrl")
.then(body=>body.json())
.then(res=>{
    let html = "";
    res.result.forEach(item=>{
        html+=
        `<li productid=${item.productId}>
        <a href="#">
            <div class="img">${item.productImgSm}</div>
            <div class="infoR">
                <div class="title">
                    <h4>${item.productName}<span>${item.productPinkage}</span>
                    </h4>
                </div>
                <div class="other">
                    <span class="diyi">${item.productFrom} |${item.productTime}</span>
                    <span class="dier">
                        <i><img src="./assets/images/QQ-1.jpg" alt=""></i>
                        <span>${item.productComCount}</span>
                    </span>
                </div>
            </div>
        </a>
    </li>
        `
    })
    $('#product ul').html(html)

    let lis= [...$('#product ul li')]


        lis.forEach(li=>{
            // console.log(li);
            li.onclick=function(){
                let productid=this.getAttribute('productid')
                // console.log(productid);
                // console.log(123);
                location.href =`../pages/dateli.html?productid=${productid}`
            }
        })

})

